package com.example.parallelTemplate.commons.task;

import com.example.parallelTemplate.commons.dto.BannerDTO;
import com.example.parallelTemplate.commons.dto.BaseRspDTO;
import com.example.parallelTemplate.commons.param.BannerParam;
import com.example.parallelTemplate.commons.req.AppInfoReq;
import com.example.parallelTemplate.commons.service.IBannerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * banner信息策略类型
 */
@Service
public class BannerStrategyTask implements IBaseTask {

    @Resource
    private IBannerService bannerService;

    @Override
    public String getTaskType() {
        return "bannerDTO";
    }

    @Override
    public BaseRspDTO<Object> execute(AppInfoReq req) {
        BannerParam bannerParam = bannerService.buildBannerParam(req);
        BannerDTO bannerDTO = bannerService.queryBannerInfo(bannerParam);
        BaseRspDTO<Object> bannerBaseRspDTO = new BaseRspDTO<Object>();
        bannerBaseRspDTO.setKey(getTaskType());
        bannerBaseRspDTO.setData(bannerDTO);
        return bannerBaseRspDTO;
    }
}
